package com.xsl.lession02.controller;

import com.xsl.lession02.pojo.ElectronicFence;
import com.xsl.lession02.pojo.FenceLocationPoint;
import com.xsl.lession02.pojo.MonitoredPerson;
import com.xsl.lession02.service.ElectronicFenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 电子围栏管理相关的业务功能
 */
@RequestMapping("electronicFence")
@RestController
public class ElectronicFenceController {

    @Autowired
    private ElectronicFenceService electronicFenceService;

    /**
     * 新增电子围栏
     *
     * @param electronicFence
     * @return
     */
    @PostMapping
    public Object createElectronicFence(@RequestBody ElectronicFence electronicFence) {
        return this.electronicFenceService.createElectronicFence(electronicFence);
    }

    /**
     * 创建监控对象
     *
     * @param monitoredPerson
     * @return
     */
    @PostMapping("addmonitoredperson")
    public Object addMonitoredPerson(@RequestBody MonitoredPerson monitoredPerson) {
        return this.electronicFenceService.addMonitoredPerson(monitoredPerson);
    }


    /**
     * 电子围栏判断
     *
     * @param fenceLocationPoint
     * @return
     */
    @PostMapping("queryfence")
    public Object querystatusbylocation(@RequestBody FenceLocationPoint fenceLocationPoint) {
        return this.electronicFenceService.querystatusbylocation(fenceLocationPoint);
    }


    /**
     * 查询电子围栏详情
     *
     * @param id
     * @return
     */
    @GetMapping("details/{id}")
    public Object queryElectronicFenceById(@PathVariable("id") String id) {
        return this.electronicFenceService.queryElectronicFenceById(id);
    }

}
